/* -------------------------------------------------------- Declare -- */
/**
 * 监听菜单选中状态
 */
const Index = (data, pathname) => {
	// let hash = window.location.hash
	// let pathname = hash ? hash.replace('#','') : window.location.pathname
	const deep = data => {
		for(let i in data){
			const v = data[i]
			const { children, path } = v
			if(Array.isArray(children)) {
				v.checked = v.checked ? v.checked : pathname.startsWith(path + '/')
				deep(children)
			}else{
				let checked = pathname === path || pathname.startsWith(path + '/')
				v.checked = checked
			}
		}
		return data
	}
	data = deep( data )
	return data
}
export default Index